package com.hxx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxx.entity.MemberEntity;
import com.hxx.mapper.MemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hxx.service.MemberService;

@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberEntity>
        implements MemberService {
    @Autowired
    private  MemberMapper memberMapper;
    @Override
    public Page<MemberEntity> listPage(Page<MemberEntity> page, String mobile) {
        return memberMapper.selectPage(page,
                new LambdaQueryWrapper<MemberEntity>()
                        .eq(mobile!=null,MemberEntity::getMobile,mobile)
        );
    }

    @Override
    public boolean findByMobile(String mobile) {
        if (memberMapper.selectOne(new LambdaQueryWrapper<MemberEntity>()
                        .eq(MemberEntity::getMobile,mobile))!=null)
            return true;
        return false;
    }

    @Override
    public MemberEntity login(String mobile) {
        MemberEntity memberEntity = memberMapper.selectOne(new LambdaQueryWrapper<MemberEntity>().eq(MemberEntity::getMobile, mobile));
        return memberEntity;
    }
}
